<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>权限列表</title>
    <script type="text/javascript" src="/dep/jquery/jquery-1.9.1.min.js"></script>
    <script type="text/javascript">


function sysupdate(obj,sid,uid) {
    var b = true;
    if (obj.checked) {
        if (b && confirm("确认添加该权限吗？")) {
            {
                $.ajax({
                    type: "POST",
                    ContentType:"text/html",
                    dataType:"json",
                    url: '/access/access-add.html',
                    data: {userId: uid,
                        projectId:sid
                    },
                    success: function () {
                    }
                });
            }
        }

    } else {
        if (b && confirm("确认移除该权限吗？")) {
            {
                $.ajax({
                    type: "POST",
                    ContentType:"text/html",
                    dataType:"json",
                    url: '/access/access-del.html',
                    data: {userId: uid,
                        projectId:sid
                    },
                    success: function () {
                    }
                });
            }
        }
    }
}
    </script>
</head>
<body>
<div>
    <table style="background-color: #eee">
        <tr>
            <td colspan="3" style="text-align: right">
                <a href="/sys/loginout.html">退出登录</a>
            </td>
        </tr>
        <tr>
            <td>序号</td>
            <td>用户名</td>
            <td align="center">权限</td>
        </tr>
        <c:forEach items="${users}" var="element" varStatus="status">
            <tr>
                <td>${status.count}</td>
                <td>${element.username}
                    <input type="hidden" value="${element.id}">
                </td>
                <td>
                    <c:forEach items="${projects}" var="sys">
                        <input type="checkbox" value="${sys.id}" name="userSystems[${status.count}]" onclick="sysupdate(this,${sys.id},${element.id})"
                               <c:if test="${element.userProject.contains(sys.id)}">checked="checked"</c:if> ><span>${sys.projectName}</span>
                    </c:forEach>
                </td>
            </tr>
        </c:forEach>
    </table>
</div>
</body>
</html>